
package com.fxp.project.jiuselu.web.business.v1.controller.coupon;

import com.fxp.project.jiuselu.web.base.controller.BaseController;
import com.fxp.project.jiuselu.web.base.request.ReqBase;
import com.fxp.project.jiuselu.web.domain.CommonResult;
import com.fxp.project.jiuselu.web.models.config.entity.JslConfig;
import com.fxp.project.jiuselu.web.models.coupon.entity.JslCoupon;
import com.fxp.project.jiuselu.web.models.coupon.qo.UserReceiveCouponQo;
import com.fxp.project.jiuselu.web.models.coupon.service.IJslCouponService;
import com.fxp.project.jiuselu.web.models.coupon.service.IJslUserCouponService;
import com.fxp.project.jiuselu.web.models.coupon.vo.RegistCouponVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * ClassName:CouponController<br/>
 * Function: 首页提示的优惠券信息<br/>
 * Date:2021年11月01日 15:52<br/>
 *
 * @author Kai.Wang
 * @version 1.0.0
 * @see
 * @since JDK 8
 */
@RestController
@RequestMapping("/v1/coupon")
public class CouponController extends BaseController {
    @Autowired
    IJslCouponService jslCouponService;
    @Autowired
    private IJslUserCouponService jslUserCouponService ;

    /**
     * @Description 领取优惠券
     * @Date 0:33 2022/1/26
     * @Param [userReceiveCouponQo]
     * @return com.fxp.project.jiuselu.web.domain.CommonResult
     * @Author M_
     **/
    @PostMapping("/receiveCoupon")
    @CrossOrigin
    public CommonResult receiveCoupon(@RequestBody UserReceiveCouponQo userReceiveCouponQo) {
        jslUserCouponService.receiveCoupon(userReceiveCouponQo,super.getCurrentUserInfo().getUserId());
        return CommonResult.success("");
    }

    /**
     * @Description 领取注册发送的优惠券
     * @Date 20:16 2022/1/27
     * @Param [userReceiveCouponQo]
     * @return com.fxp.project.jiuselu.web.domain.CommonResult
     * @Author M_
     **/
    @PostMapping("/receiveRegistCoupon")
    @CrossOrigin
    public CommonResult receiveRegistCoupon() {
        return CommonResult.success(jslUserCouponService.receiveRegistCoupon(super.getCurrentUserInfo().getUserId()));
    }
    public CommonResult list(){
        return CommonResult.success(null);
    }


    /**
     * @Description 领取注册发送的优惠券
     * @Date 20:16 2022/1/27
     * @Param [userReceiveCouponQo]
     * @return com.fxp.project.jiuselu.web.domain.CommonResult
     * @Author M_
     **/
    @GetMapping("/registCoupon")
    public CommonResult registCoupon(LocalDateTime endTime) {
        return CommonResult.success(jslUserCouponService.registCoupon(endTime));
    }

}
